import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/basic_information/basic_department_entity.dart';

BasicDepartmentEntity $BasicDepartmentEntityFromJson(Map<String, dynamic> json) {
  final BasicDepartmentEntity basicDepartmentEntity = BasicDepartmentEntity();
  final List<BasicDepartmentEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<BasicDepartmentEntity>(e) as BasicDepartmentEntity).toList();
  if (children != null) {
    basicDepartmentEntity.children = children;
  }
  final String? departmentName = jsonConvert.convert<String>(json['departmentName']);
  if (departmentName != null) {
    basicDepartmentEntity.departmentName = departmentName;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    basicDepartmentEntity.id = id;
  }
  final String? pid = jsonConvert.convert<String>(json['pid']);
  if (pid != null) {
    basicDepartmentEntity.pid = pid;
  }
  return basicDepartmentEntity;
}

Map<String, dynamic> $BasicDepartmentEntityToJson(BasicDepartmentEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['children'] = entity.children.map((v) => v.toJson()).toList();
  data['departmentName'] = entity.departmentName;
  data['id'] = entity.id;
  data['pid'] = entity.pid;
  return data;
}

extension BasicDepartmentEntityExtension on BasicDepartmentEntity {
  BasicDepartmentEntity copyWith({
    List<BasicDepartmentEntity>? children,
    String? departmentName,
    String? id,
    String? pid,
  }) {
    return BasicDepartmentEntity()
      ..children = children ?? this.children
      ..departmentName = departmentName ?? this.departmentName
      ..id = id ?? this.id
      ..pid = pid ?? this.pid;
  }
}
